package com.google.android.material.floatingactionbutton;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.FloatEvaluator;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.content.res.ColorStateList;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;
import b.f.l.s;
import c.b.a.b.c0.n;
import java.util.ArrayList;
import java.util.Iterator;

class b {
    static final TimeInterpolator F = c.b.a.b.m.a.f1876c;
    static final int[] G = {16842919, 16842910};
    static final int[] H = {16843623, 16842908, 16842910};
    static final int[] I = {16842908, 16842910};
    static final int[] J = {16843623, 16842910};
    static final int[] K = {16842910};
    static final int[] L = new int[0];
    private final Rect A = new Rect();
    private final RectF B = new RectF();
    private final RectF C = new RectF();
    private final Matrix D = new Matrix();
    private ViewTreeObserver.OnPreDrawListener E;

    /* renamed from: a  reason: collision with root package name */
    c.b.a.b.c0.k f2294a;

    /* renamed from: b  reason: collision with root package name */
    c.b.a.b.c0.g f2295b;

    /* renamed from: c  reason: collision with root package name */
    Drawable f2296c;

    /* renamed from: d  reason: collision with root package name */
    a f2297d;
    Drawable e;
    boolean f;
    boolean g = true;
    float h;
    float i;
    float j;
    int k;
    private final com.google.android.material.internal.e l;
    private c.b.a.b.m.h m;
    private c.b.a.b.m.h n;
    /* access modifiers changed from: private */
    public Animator o;
    private c.b.a.b.m.h p;
    private c.b.a.b.m.h q;
    private float r;
    /* access modifiers changed from: private */
    public float s = 1.0f;
    private int t;
    /* access modifiers changed from: private */
    public int u = 0;
    private ArrayList<Animator.AnimatorListener> v;
    private ArrayList<Animator.AnimatorListener> w;
    private ArrayList<i> x;
    final FloatingActionButton y;
    final c.b.a.b.b0.b z;

    class a extends AnimatorListenerAdapter {

        /* renamed from: a  reason: collision with root package name */
        private boolean f2298a;

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ boolean f2299b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ j f2300c;

        a(boolean z, j jVar) {
            this.f2299b = z;
            this.f2300c = jVar;
        }

        public void onAnimationCancel(Animator animator) {
            this.f2298a = true;
        }

        public void onAnimationEnd(Animator animator) {
            int unused = b.this.u = 0;
            Animator unused2 = b.this.o = null;
            if (!this.f2298a) {
                b.this.y.b(this.f2299b ? 8 : 4, this.f2299b);
                j jVar = this.f2300c;
                if (jVar != null) {
                    jVar.b();
                }
            }
        }

        public void onAnimationStart(Animator animator) {
            b.this.y.b(0, this.f2299b);
            int unused = b.this.u = 1;
            Animator unused2 = b.this.o = animator;
            this.f2298a = false;
        }
    }

    /* renamed from: com.google.android.material.floatingactionbutton.b$b  reason: collision with other inner class name */
    class C0100b extends AnimatorListenerAdapter {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ boolean f2302a;

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ j f2303b;

        C0100b(boolean z, j jVar) {
            this.f2302a = z;
            this.f2303b = jVar;
        }

        public void onAnimationEnd(Animator animator) {
            int unused = b.this.u = 0;
            Animator unused2 = b.this.o = null;
            j jVar = this.f2303b;
            if (jVar != null) {
                jVar.a();
            }
        }

        public void onAnimationStart(Animator animator) {
            b.this.y.b(0, this.f2302a);
            int unused = b.this.u = 2;
            Animator unused2 = b.this.o = animator;
        }
    }

    class c extends c.b.a.b.m.g {
        c() {
        }

        /* renamed from: a */
        public Matrix evaluate(float f, Matrix matrix, Matrix matrix2) {
            float unused = b.this.s = f;
            return super.a(f, matrix, matrix2);
        }
    }

    class d implements TypeEvaluator<Float> {

        /* renamed from: a  reason: collision with root package name */
        FloatEvaluator f2306a = new FloatEvaluator();

        d(b bVar) {
        }

        /* renamed from: a */
        public Float evaluate(float f, Float f2, Float f3) {
            float floatValue = this.f2306a.evaluate(f, f2, f3).floatValue();
            if (floatValue < 0.1f) {
                floatValue = 0.0f;
            }
            return Float.valueOf(floatValue);
        }
    }

    class e implements ViewTreeObserver.OnPreDrawListener {
        e() {
        }

        public boolean onPreDraw() {
            b.this.F();
            return true;
        }
    }

    private class f extends l {
        f(b bVar) {
            super(bVar, (a) null);
        }

        /* access modifiers changed from: protected */
        public float a() {
            return 0.0f;
        }
    }

    private class g extends l {
        g() {
            super(b.this, (a) null);
        }

        /* access modifiers changed from: protected */
        public float a() {
            b bVar = b.this;
            return bVar.h + bVar.i;
        }
    }

    private class h extends l {
        h() {
            super(b.this, (a) null);
        }

        /* access modifiers changed from: protected */
        public float a() {
            b bVar = b.this;
            return bVar.h + bVar.j;
        }
    }

    interface i {
        void a();

        void b();
    }

    interface j {
        void a();

        void b();
    }

    private class k extends l {
        k() {
            super(b.this, (a) null);
        }

        /* access modifiers changed from: protected */
        public float a() {
            return b.this.h;
        }
    }

    private abstract class l extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener {

        /* renamed from: a  reason: collision with root package name */
        private boolean f2308a;

        /* renamed from: b  reason: collision with root package name */
        private float f2309b;

        /* renamed from: c  reason: collision with root package name */
        private float f2310c;

        private l() {
        }

        /* synthetic */ l(b bVar, a aVar) {
            this();
        }

        /* access modifiers changed from: protected */
        public abstract float a();

        public void onAnimationEnd(Animator animator) {
            b.this.c0((float) ((int) this.f2310c));
            this.f2308a = false;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            if (!this.f2308a) {
                c.b.a.b.c0.g gVar = b.this.f2295b;
                this.f2309b = gVar == null ? 0.0f : gVar.v();
                this.f2310c = a();
                this.f2308a = true;
            }
            b bVar = b.this;
            float f = this.f2309b;
            bVar.c0((float) ((int) (f + ((this.f2310c - f) * valueAnimator.getAnimatedFraction()))));
        }
    }

    b(FloatingActionButton floatingActionButton, c.b.a.b.b0.b bVar) {
        this.y = floatingActionButton;
        this.z = bVar;
        com.google.android.material.internal.e eVar = new com.google.android.material.internal.e();
        this.l = eVar;
        eVar.a(G, i(new h()));
        this.l.a(H, i(new g()));
        this.l.a(I, i(new g()));
        this.l.a(J, i(new g()));
        this.l.a(K, i(new k()));
        this.l.a(L, i(new f(this)));
        this.r = this.y.getRotation();
    }

    private boolean W() {
        return s.L(this.y) && !this.y.isInEditMode();
    }

    private void d0(ObjectAnimator objectAnimator) {
        if (Build.VERSION.SDK_INT == 26) {
            objectAnimator.setEvaluator(new d(this));
        }
    }

    private void g(float f2, Matrix matrix) {
        matrix.reset();
        Drawable drawable = this.y.getDrawable();
        if (drawable != null && this.t != 0) {
            RectF rectF = this.B;
            RectF rectF2 = this.C;
            rectF.set(0.0f, 0.0f, (float) drawable.getIntrinsicWidth(), (float) drawable.getIntrinsicHeight());
            int i2 = this.t;
            rectF2.set(0.0f, 0.0f, (float) i2, (float) i2);
            matrix.setRectToRect(rectF, rectF2, Matrix.ScaleToFit.CENTER);
            int i3 = this.t;
            matrix.postScale(f2, f2, ((float) i3) / 2.0f, ((float) i3) / 2.0f);
        }
    }

    private AnimatorSet h(c.b.a.b.m.h hVar, float f2, float f3, float f4) {
        ArrayList arrayList = new ArrayList();
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.y, View.ALPHA, new float[]{f2});
        hVar.e("opacity").a(ofFloat);
        arrayList.add(ofFloat);
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.y, View.SCALE_X, new float[]{f3});
        hVar.e("scale").a(ofFloat2);
        d0(ofFloat2);
        arrayList.add(ofFloat2);
        ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(this.y, View.SCALE_Y, new float[]{f3});
        hVar.e("scale").a(ofFloat3);
        d0(ofFloat3);
        arrayList.add(ofFloat3);
        g(f4, this.D);
        ObjectAnimator ofObject = ObjectAnimator.ofObject(this.y, new c.b.a.b.m.f(), new c(), new Matrix[]{new Matrix(this.D)});
        hVar.e("iconScale").a(ofObject);
        arrayList.add(ofObject);
        AnimatorSet animatorSet = new AnimatorSet();
        c.b.a.b.m.b.a(animatorSet, arrayList);
        return animatorSet;
    }

    private ValueAnimator i(l lVar) {
        ValueAnimator valueAnimator = new ValueAnimator();
        valueAnimator.setInterpolator(F);
        valueAnimator.setDuration(100);
        valueAnimator.addListener(lVar);
        valueAnimator.addUpdateListener(lVar);
        valueAnimator.setFloatValues(new float[]{0.0f, 1.0f});
        return valueAnimator;
    }

    private c.b.a.b.m.h k() {
        if (this.n == null) {
            this.n = c.b.a.b.m.h.c(this.y.getContext(), c.b.a.b.a.design_fab_hide_motion_spec);
        }
        c.b.a.b.m.h hVar = this.n;
        b.f.k.h.c(hVar);
        return hVar;
    }

    private c.b.a.b.m.h l() {
        if (this.m == null) {
            this.m = c.b.a.b.m.h.c(this.y.getContext(), c.b.a.b.a.design_fab_show_motion_spec);
        }
        c.b.a.b.m.h hVar = this.m;
        b.f.k.h.c(hVar);
        return hVar;
    }

    private ViewTreeObserver.OnPreDrawListener q() {
        if (this.E == null) {
            this.E = new e();
        }
        return this.E;
    }

    /* access modifiers changed from: package-private */
    public void A() {
    }

    /* access modifiers changed from: package-private */
    public void B() {
        ViewTreeObserver viewTreeObserver = this.y.getViewTreeObserver();
        ViewTreeObserver.OnPreDrawListener onPreDrawListener = this.E;
        if (onPreDrawListener != null) {
            viewTreeObserver.removeOnPreDrawListener(onPreDrawListener);
            this.E = null;
        }
    }

    /* access modifiers changed from: package-private */
    public void C(int[] iArr) {
        this.l.d(iArr);
    }

    /* access modifiers changed from: package-private */
    public void D(float f2, float f3, float f4) {
        b0();
        c0(f2);
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v3, resolved type: android.graphics.drawable.Drawable} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v4, resolved type: android.graphics.drawable.InsetDrawable} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r1v2, resolved type: android.graphics.drawable.InsetDrawable} */
    /* JADX WARNING: type inference failed for: r0v2, types: [android.graphics.drawable.Drawable] */
    /* access modifiers changed from: package-private */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void E(android.graphics.Rect r8) {
        /*
            r7 = this;
            android.graphics.drawable.Drawable r0 = r7.e
            java.lang.String r1 = "Didn't initialize content background"
            b.f.k.h.d(r0, r1)
            boolean r0 = r7.V()
            if (r0 == 0) goto L_0x0020
            android.graphics.drawable.InsetDrawable r0 = new android.graphics.drawable.InsetDrawable
            android.graphics.drawable.Drawable r2 = r7.e
            int r3 = r8.left
            int r4 = r8.top
            int r5 = r8.right
            int r6 = r8.bottom
            r1 = r0
            r1.<init>(r2, r3, r4, r5, r6)
            c.b.a.b.b0.b r8 = r7.z
            goto L_0x0024
        L_0x0020:
            c.b.a.b.b0.b r8 = r7.z
            android.graphics.drawable.Drawable r0 = r7.e
        L_0x0024:
            r8.c(r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.floatingactionbutton.b.E(android.graphics.Rect):void");
    }

    /* access modifiers changed from: package-private */
    public void F() {
        float rotation = this.y.getRotation();
        if (this.r != rotation) {
            this.r = rotation;
            Z();
        }
    }

    /* access modifiers changed from: package-private */
    public void G() {
        ArrayList<i> arrayList = this.x;
        if (arrayList != null) {
            Iterator<i> it = arrayList.iterator();
            while (it.hasNext()) {
                it.next().a();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public void H() {
        ArrayList<i> arrayList = this.x;
        if (arrayList != null) {
            Iterator<i> it = arrayList.iterator();
            while (it.hasNext()) {
                it.next().b();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public boolean I() {
        return true;
    }

    /* access modifiers changed from: package-private */
    public void J(ColorStateList colorStateList) {
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            gVar.setTintList(colorStateList);
        }
        a aVar = this.f2297d;
        if (aVar != null) {
            aVar.a(colorStateList);
        }
    }

    /* access modifiers changed from: package-private */
    public void K(PorterDuff.Mode mode) {
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            gVar.setTintMode(mode);
        }
    }

    /* access modifiers changed from: package-private */
    public final void L(float f2) {
        if (this.h != f2) {
            this.h = f2;
            D(f2, this.i, this.j);
        }
    }

    /* access modifiers changed from: package-private */
    public void M(boolean z2) {
        this.f = z2;
    }

    /* access modifiers changed from: package-private */
    public final void N(c.b.a.b.m.h hVar) {
        this.q = hVar;
    }

    /* access modifiers changed from: package-private */
    public final void O(float f2) {
        if (this.i != f2) {
            this.i = f2;
            D(this.h, f2, this.j);
        }
    }

    /* access modifiers changed from: package-private */
    public final void P(float f2) {
        this.s = f2;
        Matrix matrix = this.D;
        g(f2, matrix);
        this.y.setImageMatrix(matrix);
    }

    /* access modifiers changed from: package-private */
    public final void Q(float f2) {
        if (this.j != f2) {
            this.j = f2;
            D(this.h, this.i, f2);
        }
    }

    /* access modifiers changed from: package-private */
    public void R(ColorStateList colorStateList) {
        Drawable drawable = this.f2296c;
        if (drawable != null) {
            androidx.core.graphics.drawable.a.o(drawable, c.b.a.b.a0.b.d(colorStateList));
        }
    }

    /* access modifiers changed from: package-private */
    public void S(boolean z2) {
        this.g = z2;
        b0();
    }

    /* access modifiers changed from: package-private */
    public final void T(c.b.a.b.c0.k kVar) {
        this.f2294a = kVar;
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            gVar.setShapeAppearanceModel(kVar);
        }
        Drawable drawable = this.f2296c;
        if (drawable instanceof n) {
            ((n) drawable).setShapeAppearanceModel(kVar);
        }
        a aVar = this.f2297d;
        if (aVar != null) {
            aVar.b(kVar);
        }
    }

    /* access modifiers changed from: package-private */
    public final void U(c.b.a.b.m.h hVar) {
        this.p = hVar;
    }

    /* access modifiers changed from: package-private */
    public boolean V() {
        return true;
    }

    /* access modifiers changed from: package-private */
    public final boolean X() {
        return !this.f || this.y.getSizeDimension() >= this.k;
    }

    /* access modifiers changed from: package-private */
    public void Y(j jVar, boolean z2) {
        if (!x()) {
            Animator animator = this.o;
            if (animator != null) {
                animator.cancel();
            }
            if (W()) {
                if (this.y.getVisibility() != 0) {
                    this.y.setAlpha(0.0f);
                    this.y.setScaleY(0.0f);
                    this.y.setScaleX(0.0f);
                    P(0.0f);
                }
                c.b.a.b.m.h hVar = this.p;
                if (hVar == null) {
                    hVar = l();
                }
                AnimatorSet h2 = h(hVar, 1.0f, 1.0f, 1.0f);
                h2.addListener(new C0100b(z2, jVar));
                ArrayList<Animator.AnimatorListener> arrayList = this.v;
                if (arrayList != null) {
                    Iterator<Animator.AnimatorListener> it = arrayList.iterator();
                    while (it.hasNext()) {
                        h2.addListener(it.next());
                    }
                }
                h2.start();
                return;
            }
            this.y.b(0, z2);
            this.y.setAlpha(1.0f);
            this.y.setScaleY(1.0f);
            this.y.setScaleX(1.0f);
            P(1.0f);
            if (jVar != null) {
                jVar.a();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public void Z() {
        int i2;
        FloatingActionButton floatingActionButton;
        if (Build.VERSION.SDK_INT == 19) {
            if (this.r % 90.0f != 0.0f) {
                i2 = 1;
                if (this.y.getLayerType() != 1) {
                    floatingActionButton = this.y;
                }
            } else if (this.y.getLayerType() != 0) {
                floatingActionButton = this.y;
                i2 = 0;
            }
            floatingActionButton.setLayerType(i2, (Paint) null);
        }
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            gVar.Y((int) this.r);
        }
    }

    /* access modifiers changed from: package-private */
    public final void a0() {
        P(this.s);
    }

    /* access modifiers changed from: package-private */
    public final void b0() {
        Rect rect = this.A;
        r(rect);
        E(rect);
        this.z.a(rect.left, rect.top, rect.right, rect.bottom);
    }

    /* access modifiers changed from: package-private */
    public void c0(float f2) {
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            gVar.T(f2);
        }
    }

    public void d(Animator.AnimatorListener animatorListener) {
        if (this.w == null) {
            this.w = new ArrayList<>();
        }
        this.w.add(animatorListener);
    }

    /* access modifiers changed from: package-private */
    public void e(Animator.AnimatorListener animatorListener) {
        if (this.v == null) {
            this.v = new ArrayList<>();
        }
        this.v.add(animatorListener);
    }

    /* access modifiers changed from: package-private */
    public void f(i iVar) {
        if (this.x == null) {
            this.x = new ArrayList<>();
        }
        this.x.add(iVar);
    }

    /* access modifiers changed from: package-private */
    public final Drawable j() {
        return this.e;
    }

    /* access modifiers changed from: package-private */
    public float m() {
        return this.h;
    }

    /* access modifiers changed from: package-private */
    public boolean n() {
        return this.f;
    }

    /* access modifiers changed from: package-private */
    public final c.b.a.b.m.h o() {
        return this.q;
    }

    /* access modifiers changed from: package-private */
    public float p() {
        return this.i;
    }

    /* access modifiers changed from: package-private */
    public void r(Rect rect) {
        int sizeDimension = this.f ? (this.k - this.y.getSizeDimension()) / 2 : 0;
        float m2 = this.g ? m() + this.j : 0.0f;
        int max = Math.max(sizeDimension, (int) Math.ceil((double) m2));
        int max2 = Math.max(sizeDimension, (int) Math.ceil((double) (m2 * 1.5f)));
        rect.set(max, max2, max, max2);
    }

    /* access modifiers changed from: package-private */
    public float s() {
        return this.j;
    }

    /* access modifiers changed from: package-private */
    public final c.b.a.b.c0.k t() {
        return this.f2294a;
    }

    /* access modifiers changed from: package-private */
    public final c.b.a.b.m.h u() {
        return this.p;
    }

    /* access modifiers changed from: package-private */
    public void v(j jVar, boolean z2) {
        if (!w()) {
            Animator animator = this.o;
            if (animator != null) {
                animator.cancel();
            }
            if (W()) {
                c.b.a.b.m.h hVar = this.q;
                if (hVar == null) {
                    hVar = k();
                }
                AnimatorSet h2 = h(hVar, 0.0f, 0.0f, 0.0f);
                h2.addListener(new a(z2, jVar));
                ArrayList<Animator.AnimatorListener> arrayList = this.w;
                if (arrayList != null) {
                    Iterator<Animator.AnimatorListener> it = arrayList.iterator();
                    while (it.hasNext()) {
                        h2.addListener(it.next());
                    }
                }
                h2.start();
                return;
            }
            this.y.b(z2 ? 8 : 4, z2);
            if (jVar != null) {
                jVar.b();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public boolean w() {
        return this.y.getVisibility() == 0 ? this.u == 1 : this.u != 2;
    }

    /* access modifiers changed from: package-private */
    public boolean x() {
        return this.y.getVisibility() != 0 ? this.u == 2 : this.u != 1;
    }

    /* access modifiers changed from: package-private */
    public void y() {
        this.l.c();
    }

    /* access modifiers changed from: package-private */
    public void z() {
        c.b.a.b.c0.g gVar = this.f2295b;
        if (gVar != null) {
            c.b.a.b.c0.h.f(this.y, gVar);
        }
        if (I()) {
            this.y.getViewTreeObserver().addOnPreDrawListener(q());
        }
    }
}
